Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for prompt roles and prompt preambles #114

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

ahejlsberg
Copy link
Member

This PR adds support for prompt roles, i.e. prompt sections tagged with "system", "user", or "assistant" roles. TypeChat uses the "user" role for prompts it generates and the "assistant" role for previous LLM responses (which will be part of the prompt in repair attempts). TypeChat currently doesn't use the "system" role.

This PR also adds support for specifying a prompt preamble when processing requests. This makes it easier to implement chat-like interactions and conversation history.

@DanielRosenwasser DanielRosenwasser merged commit f9dadc8 into main Nov 7, 2023
@DanielRosenwasser DanielRosenwasser deleted the prompt-roles-and-preambles branch November 7, 2023 23:03
@Githamza
Copy link

Githamza commented Dec 3, 2023

How can I try it ? I have installed the last version (v0.0.10) of typechat but in node_modules/typechat, these additions does not exists

@thenbe
Copy link

thenbe commented Dec 4, 2023

@Githamza The version you downloaded from npm is 4 months old. Instead of installing it from npm:

  1. clone this repo to your pc
  2. build it from source
  3. see npm link or pnpm link to use your local version of typechat in other projects

@Githamza
Copy link

Githamza commented Dec 7, 2023

Thanks , I have a question ,the request parameter mandatory. If I would send a promptPreamble with system and user roles , what should I put in request param ? for me request content is the user role content ?
Actually I send the same string in request param and also in the user role ( in it's content property )

@olawalejuwonm
Copy link

How can this be used please?

@kad3nce
Copy link

kad3nce commented May 22, 2024

@olawalejuwonm, the key change is here: https://github.com/microsoft/TypeChat/pull/114/files#diff-1ece2a0b089b56f4aa22ef64be65b4305b5e890b560a39d9d12140f9a42d40f4R104

Add a user message preamble:

translator.translate(data, 'Hello there');

Add a system prompt:

translator.translate(data, [
  { role: 'system', content: 'You are an expert data anonymizer...' }
]);

@olawalejuwonm
Copy link

How do I pass the user content then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants